Bring in the changes to "finish" the XCSV stuff. This preprocesses the
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 2 Mar 2003 01:41:45 +0000 (01:41 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 2 Mar 2003 01:41:45 +0000 (01:41 +0000)
style directory and compiles it intot he binary, eliminating the *need*
(but keeping the *option*) of external style files.  It makes the style
entries look like first class citizens, showing up in help, menu option
output, and such.

This is the result of some ping-ponging with Alex...

: Modified Files:
:  Makefile csv_util.h defs.h gcdb.c internal_styles.c mkstyle.sh
:  vecs.c xcsv.c style/README.style style/csv.style
:  style/custom.style style/dna.style style/gpsdrive.style
:  style/gpsman.style style/mxf.style style/nima.style
:  style/ozi.style style/s_and_t.style style/tiger.style
:  style/xmap.style
: Removed Files:
:  csv.c dna.c gpsman.c mxf.c ozi.c tiger.c

26 files changed:
gpsbabel/Makefile
gpsbabel/csv.c [deleted file]
gpsbabel/csv_util.h
gpsbabel/defs.h
gpsbabel/dna.c [deleted file]
gpsbabel/gcdb.c
gpsbabel/gpsman.c [deleted file]
gpsbabel/internal_styles.c
gpsbabel/mkstyle.sh
gpsbabel/mxf.c [deleted file]
gpsbabel/ozi.c [deleted file]
gpsbabel/style/README.style
gpsbabel/style/csv.style
gpsbabel/style/custom.style
gpsbabel/style/dna.style
gpsbabel/style/gpsdrive.style
gpsbabel/style/gpsman.style
gpsbabel/style/mxf.style
gpsbabel/style/nima.style
gpsbabel/style/ozi.style
gpsbabel/style/s_and_t.style
gpsbabel/style/tiger.style
gpsbabel/style/xmap.style
gpsbabel/tiger.c [deleted file]
gpsbabel/vecs.c
gpsbabel/xcsv.c

index bb85b8977a33bbe5689d57a6982bf86ab3d2281f..c63bca6acf156a546eb6bd2d88a76f667e5f2c06 100644 (file)
@@ -2,9 +2,9 @@
 CFLAGS=-g -Icoldsync
 INSTALL_TARGETDIR=/usr/local/
 
-FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
-       gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \
-       psp.o mxf.o holux.o garmin.o ozi.o tmpro.o dna.o tpg.o gpsdrive.o \
+FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o \
+       gpsutil.o pcx.o cetus.o gpspilot.o magnav.o \
+       psp.o holux.o garmin.o tmpro.o tpg.o \
        xcsv.o xmapwpt.o gcdb.o internal_styles.o
 
 FILTERS=position.o duplicate.o
@@ -44,11 +44,12 @@ install:
 
 # Nerdy release stuff that needs to work only on Linux.
 
-internal_styles.c:
+internal_styles.c: mkstyle.sh style/csv.style
        ./mkstyle.sh > internal_styles.c
 
 dep:
        make clean && make CC="gcc -MMD"  && cat *.d */*.d > /tmp/dep
+       (echo "internal_styles.c: mkstyle.sh" ; ls style/*.style) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
 VERSIONU=1_1_1_beta02122003
diff --git a/gpsbabel/csv.c b/gpsbabel/csv.c
deleted file mode 100644 (file)
index 8faaf76..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-  Comma separated value files.
-  LONG, LAT, NAME.
-  
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-#include "csv_util.h"
-#include <ctype.h>
-
-static FILE *file_in;
-static FILE *file_out;
-static void *mkshort_handle;
-static char *psn;
-
-static
-arglist_t csv_args[] = {
-       {"prefer_shortname", &psn, "Use shortnames even if longer names available"},
-       {0, 0, 0}
-};
-
-#define MYNAME "CSV"
-
-static void
-rd_init(const char *fname, const char *args)
-{
-       file_in = fopen(fname, "r");
-       mkshort_handle = mkshort_new_handle();
-
-       if (file_in == NULL) {
-               fatal(MYNAME ": Cannot open %s for reading\n", fname);
-       }
-}
-
-static void
-rd_deinit(void)
-{
-       mkshort_del_handle(mkshort_handle);
-       fclose(file_in);
-}
-
-static void
-wr_init(const char *fname, const char *args)
-{
-       file_out = fopen(fname, "w");
-
-       if (file_out == NULL) {
-               fatal(MYNAME ": Cannot open %s for writing\n", fname);
-       }
-}
-
-static void
-xmap_wr_init(const char *fname, const char *args)
-{
-       wr_init(fname, args);
-       fprintf(file_out, "BEGIN SYMBOL\n");
-}
-
-
-static void
-wr_deinit(void)
-{
-       fclose(file_out);
-}
-
-static void
-xmap_wr_deinit(void)
-{
-       fprintf(file_out, "END\n");
-       wr_deinit();
-}
-
-static void
-data_read(void)
-{
-       char buff[1024];
-       char *s;
-       int i;
-       waypoint *wpt_tmp;
-       int linecount = 0;
-
-       do {
-               linecount++;
-               memset(buff, '\0', sizeof(buff));
-               fgets(buff, sizeof(buff), file_in);
-                 
-               if (strlen(buff)) {
-
-                   wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1);
-                   s = buff;
-
-                   /* data delimited by commas, not enclosed */
-                   s = csv_lineparse(s, ",", "", linecount);
-
-                   i = 0;
-
-               while (s) {
-                       switch (i) {
-                       case 0:
-                               wpt_tmp->position.latitude.degrees = atof(s);
-                               break;
-                       case 1:
-                               wpt_tmp->position.longitude.degrees = atof(s);
-                               break;
-                       case 2:
-                               wpt_tmp->description = csv_stringtrim(s, " ");
-                               break;
-                       default:
-                               fprintf (stderr, "%s: Warning: unmapped data fields on line %d.\n", 
-                                       MYNAME, linecount);
-                               break;
-                       }
-                       i++;
-
-                       s = csv_lineparse(NULL, ",", "", linecount);
-               }
-           
-               wpt_tmp->creation_time = time(NULL);
-               
-               /* We'll make up our own shortname. */
-               if (wpt_tmp->description) {
-                       wpt_tmp->shortname = mkshort(mkshort_handle, wpt_tmp->description);
-                       waypt_add(wpt_tmp);
-               }
-               else {
-                       waypt_free(wpt_tmp);
-               }
-
-       } else {
-               /* empty line */
-       }
-
-    } while (!feof(file_in));
-}
-
-static void
-csv_waypt_pr(const waypoint *wpt)
-{
-       double lon,lat;
-       char * description = NULL;
-
-       lon = wpt->position.longitude.degrees;
-       lat = wpt->position.latitude.degrees;
-
-       if (psn)  {
-               if (wpt->shortname) 
-                   description = csv_stringclean(wpt->shortname, ",\"");
-       } else {
-               if (wpt->description) 
-                   description = csv_stringclean(wpt->description, ",\"");
-       }
-
-       if ((description == NULL) && wpt->notes)
-           description = csv_stringclean(wpt->notes, ",\"");
-
-       fprintf(file_out, "%08.5f, %08.5f, %s\n",
-               lat,
-               lon,
-               description);
-               
-       if (description)
-               xfree(description);
-
-}
-
-static void
-data_write(void)
-{
-       waypt_disp_all(csv_waypt_pr);
-}
-
-ff_vecs_t csv_vecs = {
-       rd_init,
-       wr_init,
-       rd_deinit,
-       wr_deinit,
-       data_read,
-       data_write,
-       csv_args
-};
-
-ff_vecs_t xmap_vecs = {
-       rd_init,
-       xmap_wr_init,
-       rd_deinit,
-       xmap_wr_deinit,
-       data_read,
-       data_write,
-};
index 122b274175b78b6767139840c2977fe076de3007..08718537c6da0a5bd0612ed3728af9525a1999b2 100644 (file)
@@ -114,6 +114,10 @@ typedef struct {
     int ofield_ct;             /* actual # of ofields */
     
     FILE * xcsvfp;             /* ptr to current *open* data file */
+
+    char * description;                /* Description for help text */
+    int shortlen;              /* preferred shortname length */
+    char * extension;          /* preferred filename extension (for wrappers)*/
     
 } xcsv_file_t;
 
index cef56435d0cdf66aa3e3bff593ab1b1178aa6705..f6042da7e2f3c7db33d4e817a4a98a5ac556e8d5 100644 (file)
@@ -248,8 +248,6 @@ typedef struct ff_vecs {
 typedef struct style_vecs {
        const char *name;
        const char *style_buf;
-       const char *desc;
-       const char *ext;
 } style_vecs_t;
 extern style_vecs_t style_list[];
 
diff --git a/gpsbabel/dna.c b/gpsbabel/dna.c
deleted file mode 100644 (file)
index 4fbc8c3..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-  Comma separated value files for Navitrak DNA waypoints.
-  WPT#,Northing,Easting,Name
-  
-  10/1/02 - t. e. zickus, shamelessly hacked from csv.c, below.
-
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-#include "csv_util.h"
-#include <ctype.h>
-
-static FILE *file_in;
-static FILE *file_out;
-static void *mkshort_handle;
-
-#define MYNAME "DNA"
-
-static void
-rd_init(const char *fname, const char *args)
-{
-       file_in = fopen(fname, "r");
-       mkshort_handle = mkshort_new_handle();
-
-       if (file_in == NULL) {
-               fatal(MYNAME ": Cannot open %s for reading\n", fname);
-       }
-}
-
-static void
-rd_deinit(void)
-{
-       mkshort_del_handle(mkshort_handle);
-       fclose(file_in);
-}
-
-static void
-wr_init(const char *fname, const char *args)
-{
-       file_out = fopen(fname, "w");
-
-       if (file_out == NULL) {
-               fatal(MYNAME ": Cannot open %s for writing\n", fname);
-       }
-}
-
-static void
-wr_deinit(void)
-{
-       fclose(file_out);
-}
-
-static void
-data_read(void)
-{
-       char buff[1024];
-       char *s;
-       int i;
-       waypoint *wpt_tmp;
-       int linecount = 0;
-
-       do {
-               linecount++;
-               memset(buff, '\0', sizeof(buff));
-               fgets(buff, sizeof(buff), file_in);
-                 
-               if (strlen(buff)) {
-
-                   wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1);
-                   s = buff;
-
-                   /* data delimited by commas, not enclosed */
-                   s = csv_lineparse(s, ",", "", linecount);
-
-                   i = 0;
-
-               while (s) {
-                       switch (i) {
-                       case 0: /* WPT #, skip. */
-                         break;
-                       case 1:
-                               wpt_tmp->position.latitude.degrees = atof(s);
-                               break;
-                       case 2:
-                               wpt_tmp->position.longitude.degrees = atof(s);
-                               break;
-                       case 3:
-                               wpt_tmp->description = csv_stringtrim(s, " ");
-                               break;
-                       default:
-                               fprintf (stderr, "%s: Warning: unmapped data fields on line %d.\n", 
-                                       MYNAME, linecount);
-                               break;
-                       }
-                       i++;
-
-                       s = csv_lineparse(NULL, ",", "", linecount);
-               }
-           
-               wpt_tmp->creation_time = time(NULL);
-               
-               /* We'll make up our own shortname. */
-               wpt_tmp->shortname = mkshort(mkshort_handle, wpt_tmp->description);
-               
-               waypt_add(wpt_tmp);
-
-       } else {
-               /* empty line */
-       }
-
-    } while (!feof(file_in));
-}
-
-static void
-dna_waypt_pr(const waypoint *wpt)
-{
-       double lon,lat;
-       char * description = NULL;
-       static int wpt_num = 0;
-
-       lon = wpt->position.longitude.degrees;
-       lat = wpt->position.latitude.degrees;
-
-        if (wpt->description) 
-           description = csv_stringclean(wpt->description, ",\"");
-
-       fprintf(file_out, "%d,%08.5f,%08.5f,%s\n",
-               wpt_num++,
-               lat,
-               lon,
-               description);
-               
-       if (description)
-               xfree(description);
-
-}
-
-static void
-data_write(void)
-{
-       waypt_disp_all(dna_waypt_pr);
-}
-
-ff_vecs_t dna_vecs = {
-       rd_init,
-       wr_init,
-       rd_deinit,
-       wr_deinit,
-       data_read,
-       data_write,
-};
index 20187d1861ddd4109e692f7d68dc690e1930c4e9..2dd5c7cd8d190cffbc9901c30eae73e83ac3bb20 100644 (file)
@@ -233,6 +233,8 @@ gcdb_add_to_rec(struct dbrec *rec, char *fldname, gcdb_rectype rectype, void *da
                abort();
        }
        rec_cnt++;
+
+       return length;
 }
 
 static void
diff --git a/gpsbabel/gpsman.c b/gpsbabel/gpsman.c
deleted file mode 100644 (file)
index fc15d5b..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-
-static FILE *in_file;
-static FILE *out_file;
-
-#define MYNAME "GPSMAN"
-
-static void
-gpsman_rd_init(const char *fname, const char *args)
-{
-       in_file = fopen(fname, "r");
-       if (in_file == NULL) {
-               fatal(MYNAME ": Cannot open %s for reading\n", fname);
-       }
-
-}
-static void
-gpsman_rd_deinit(void)
-{
-       fclose(in_file);
-}
-
-static void
-gpsman_wr_init(const char *fname, const char *args)
-{
-       out_file = fopen(fname, "w");
-       if (out_file == NULL) {
-               fatal(MYNAME ": Cannot open %s for writing\n", fname);
-       }
-
-       fprintf(out_file, "!Format: DDD 1 WGS 84\n");
-}
-
-static void
-gpsman_wr_deinit(void)
-{
-       fclose(out_file);
-}
-
-static void
-gpsman_disp(const waypoint *waypointp)
-{
-       fprintf(out_file, "%-8.8s\t%s\t", 
-               waypointp->shortname, waypointp->description);
-       fprintdms(out_file, &waypointp->position.latitude, 1);
-       fprintdms(out_file, &waypointp->position.longitude, 0);
-       fprintf(out_file,"\n");
-}
-
-static void
-gpsman_parse_cmd(const char *cmd)
-{
-       return;
-}
-
-static void
-gpsman_read(void)
-{
-       char latdir, londir;
-       double latf, lonf;
-       int lonm, latm;
-       double lat, lon;
-       char sname[20];
-       char descr[100];
-       char ibuf[100];
-       waypoint *wpt_tmp;
-
-       while( fgets(ibuf, sizeof(ibuf), in_file)) {
-               if (ibuf[0] == '%' || ibuf[0] == '\n' ) {
-                       continue;
-               }
-               if (ibuf[0] == '!') {
-                       gpsman_parse_cmd(&ibuf[1]);
-                       continue;
-               }
-
-               sscanf(ibuf, "%[^\t] %[^\t] %c%d %lf %c%d %lf",
-                       sname, descr, &latdir, &latm, &latf, &londir, &lonm, &lonf);
-
-               wpt_tmp = xcalloc(sizeof(*wpt_tmp),1);
-
-               lat = latm + latf;
-               lon = lonm + lonf;
-
-               if (latdir == 'S') lat = -lat;
-               if (londir == 'W') lon = -lon;
-
-               wpt_tmp->position.longitude.degrees = lon;
-               wpt_tmp->position.latitude.degrees = lat;
-               wpt_tmp->shortname = xstrdup(sname);
-               wpt_tmp->description = xstrdup(descr);
-
-               waypt_add(wpt_tmp);
-       }
-}
-
-static void
-gpsman_write(void)
-{
-       fprintf(out_file, "!W:\n");
-       waypt_disp_all(gpsman_disp);
-}
-
-ff_vecs_t gpsman_vecs = {
-       gpsman_rd_init, 
-       gpsman_wr_init, 
-       gpsman_rd_deinit,
-       gpsman_wr_deinit,
-       gpsman_read,
-       gpsman_write,
-};
index 67cbb79e0a411e71122c11bc28f0aa65756074fd..8090c5d73b9bb77f23439aad422db9666fa76cef 100644 (file)
 static char csv[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Delorme SA 9.0 CSV"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As defined in csv.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMASPACE"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        LON_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Delorme SA 9.0 CSV\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"DESCRIPTION   Comma separated values\n"
+"SHORTLEN      8\n"
+"#\n"
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMASPACE\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
 ;
 static char custom[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Custom \"Everything\" Style"
-"# Author: Alex Mottram"
-"#   Date: 11/24/2002"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMA"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"#"
-"# HEADER STUFF:"
-"#"
-"PROLOGUE      Prologue Line 1"
-"PROLOGUE      Prologue Line 2"
-
-"#"
-"# INDIVIDUAL DATA FIELDS:"
-"#"
-"IFIELD        CONSTANT, \"\", \"CONSTANT\""
-"IFIELD        INDEX, \"\", \"%d\""
-"IFIELD        LAT_DECIMAL, \"\", \"%f\""
-"IFIELD        LAT_DIR, \"\", \"%c\""
-"IFIELD        LON_DECIMAL, \"\", \"%f\""
-"IFIELD        LON_DIR, \"\", \"%c\""
-"IFIELD        ICON_DESCR, \"\", \"%s\""
-"IFIELD        SHORTNAME, \"\", \"%s\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
-"IFIELD        NOTES, \"\", \"%s\""
-"IFIELD        URL, \"\", \"%s\"               "
-"IFIELD        URL_LINK_TEXT, \"\", \"%s\""
-"IFIELD        ALT_METERS, \"\", \"%fM\""
-"IFIELD        ALT_FEET, \"\", \"%fF\""
-"IFIELD        LAT_DECIMALDIR, \"\", \"%f/%c\""
-"IFIELD        LON_DECIMALDIR, \"\", \"%f/%c\""
-"IFIELD        LAT_DIRDECIMAL, \"\", \"%c/%f\""
-"IFIELD        LON_DIRDECIMAL, \"\", \"%c/%f\""
-"IFIELD        LAT_INT32DEG, \"\", \"%ld\""
-"IFIELD        LON_INT32DEG, \"\", \"%ld\""
-"IFIELD        TIMET_TIME, \"\", \"%ld\""
-"IFIELD        EXCEL_TIME, \"\", \"%f\""
-
-"# EPILOGUE: "
-"EPILOGUE      Epilogue Line 1"
-"EPILOGUE      Epilogue Line 2"
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Custom \"Everything\" Style\n"
+"# Author: Alex Mottram\n"
+"#   Date: 11/24/2002\n"
+"#\n"
+"#\n"
+
+"DESCRIPTION           Custom \"Everything\" Style\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMA\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"#\n"
+"# HEADER STUFF:\n"
+"#\n"
+"PROLOGUE      Prologue Line 1\n"
+"PROLOGUE      Prologue Line 2\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS:\n"
+"#\n"
+"IFIELD        CONSTANT, \"\", \"CONSTANT\"\n"
+"IFIELD        INDEX, \"\", \"%d\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        LAT_DIR, \"\", \"%c\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        LON_DIR, \"\", \"%c\"\n"
+"IFIELD        ICON_DESCR, \"\", \"%s\"\n"
+"IFIELD        SHORTNAME, \"\", \"%s\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
+"IFIELD        NOTES, \"\", \"%s\"\n"
+"IFIELD        URL, \"\", \"%s\"               \n"
+"IFIELD        URL_LINK_TEXT, \"\", \"%s\"\n"
+"IFIELD        ALT_METERS, \"\", \"%fM\"\n"
+"IFIELD        ALT_FEET, \"\", \"%fF\"\n"
+"IFIELD        LAT_DECIMALDIR, \"\", \"%f/%c\"\n"
+"IFIELD        LON_DECIMALDIR, \"\", \"%f/%c\"\n"
+"IFIELD        LAT_DIRDECIMAL, \"\", \"%c/%f\"\n"
+"IFIELD        LON_DIRDECIMAL, \"\", \"%c/%f\"\n"
+"IFIELD        LAT_INT32DEG, \"\", \"%ld\"\n"
+"IFIELD        LON_INT32DEG, \"\", \"%ld\"\n"
+"IFIELD        TIMET_TIME, \"\", \"%ld\"\n"
+"IFIELD        EXCEL_TIME, \"\", \"%f\"\n"
+
+"# EPILOGUE: \n"
+"EPILOGUE      Epilogue Line 1\n"
+"EPILOGUE      Epilogue Line 2\n"
 ;
 static char dna[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: DNA Marker Format"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As defined in dna.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMA"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        INDEX, \"\", \"%d\""
-"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        LON_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: DNA Marker Format\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As defined in dna.c\n"
+"#\n"
+"#\n"
+
+"DESCRIPTION           Navitrak DNA marker format\n"
+"EXTENSION             dna\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMA\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        INDEX, \"\", \"%d\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
 
 ;
 static char gpsdrive[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: GPSDrive"
-"# Author: Alex Mottram"
-"#   Date: 12/11/2002"
-"#"
-"# "
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               SPACE"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              ,\""
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-
-"IFIELD        ANYNAME, \"\", \"%s\""
-"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        LON_DECIMAL, \"\", \"%08.5f\""
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: GPSDrive\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/11/2002\n"
+"#\n"
+"# \n"
+"#\n"
+
+"DESCRIPTION           GpsDrive Format\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               SPACE\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              ,\"\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+
+"IFIELD        SHORTNAME, \"\", \"%s\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+
+"OFIELD        ANYNAME, \"\", \"%s\"\n"
+"OFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"OFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
 ;
 static char gpsman[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: GPSMAN Format"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As defined in gpsman.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               TAB"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              TAB"
-
-"PROLOGUE      !Format: DDD 1 WGS 84"
-"PROLOGUE      !W:"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        SHORTNAME, \"\", \"%-8.8s\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
-"IFIELD        LAT_DIRDECIMAL, \"\", \"%c%f\""
-"IFIELD        LON_DIRDECIMAL, \"\", \"%c%f\""
-"IFIELD        IGNORE, \"\", \"%s\""
-
-"# gpsman.c likes mkshort len = 8, whitespace = 0."
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: GPSMAN Format\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As defined in gpsman.c\n"
+"#\n"
+"#\n"
+
+"DESCRIPTION           GPSman\n"
+
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               TAB\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              TAB\n"
+
+"PROLOGUE      !Format: DDD 1 WGS 84\n"
+"PROLOGUE      !W:\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        SHORTNAME, \"\", \"%-8.8s\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
+"IFIELD        LAT_DIRDECIMAL, \"\", \"%c%f\"\n"
+"IFIELD        LON_DIRDECIMAL, \"\", \"%c%f\"\n"
+"IFIELD        IGNORE, \"\", \"%s\"\n"
+
+"# gpsman.c likes mkshort len = 8, whitespace = 0.\n"
 ;
 static char mxf[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Ozi Explorer"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As used in mxf.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMASPACE"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        LON_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
-"IFIELD        SHORTNAME, \"\", \"%s\""
-"IFIELD        IGNORE, \"\", \"%s\""
-"IFIELD        CONSTANT, \"ff0000\", \"%s\"    # COLOR"
-"IFIELD        CONSTANT, \"47\", \"%s\"                # ICON"
-
-"OFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"OFIELD        LON_DECIMAL, \"\", \"%08.5f\""
-"OFIELD        DESCRIPTION, \"\", \"\"%s\"\""
-"OFIELD        SHORTNAME, \"\", \"%s\""
-"OFIELD        DESCRIPTION, \"\", \"%s\""
-"OFIELD        CONSTANT, \"ff0000\", \"%s\"    # COLOR"
-"OFIELD        CONSTANT, \"47\", \"%s\"                # ICON"
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Ozi Explorer\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As used in mxf.c\n"
+"#\n"
+"#\n"
+
+"DESCRIPTION           MapTech Exchange Format\n"
+"EXTENSION             mxf\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMASPACE\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
+"IFIELD        SHORTNAME, \"\", \"%s\"\n"
+"IFIELD        IGNORE, \"\", \"%s\"\n"
+"IFIELD        CONSTANT, \"ff0000\", \"%s\"    # COLOR\n"
+"IFIELD        CONSTANT, \"47\", \"%s\"                # ICON\n"
+
+"OFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"OFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+"OFIELD        DESCRIPTION, \"\", \"\"%s\"\"\n"
+"OFIELD        SHORTNAME, \"\", \"%s\"\n"
+"OFIELD        DESCRIPTION, \"\", \"%s\"\n"
+"OFIELD        CONSTANT, \"ff0000\", \"%s\"    # COLOR\n"
+"OFIELD        CONSTANT, \"47\", \"%s\"                # ICON\n"
 ;
 static char nima[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: NIMA/GNIS Geographic Names File"
-"# Author: Alex Mottram"
-"#   Date: 11/24/2002"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               TAB"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              TAB"
-"PROLOGUE      RC      UFI     UNI     DD_LAT  DD_LONG DMS_LAT DMS_LONG        UTM     JOG     FC      DSG     PC      CC1     ADM1    ADM2    DIM     CC2     NT      LC      SHORT_FORM      GENERIC SORT_NAME       FULL_NAME       FULL_NAME_ND    MODIFY_DATE"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        IGNORE, \"\", \"%s\"            # RC"
-"IFIELD        IGNORE, \"\", \"%s\"            # UFI"
-"IFIELD        IGNORE, \"\", \"%s\"            # UNI"
-"IFIELD        LAT_DECIMAL, \"\", \"%f\"               # DD_LAT"
-"IFIELD        LON_DECIMAL, \"\", \"%f\"               # DD_LON"
-"IFIELD        IGNORE, \"\", \"%s\"            # DMS_LAT"
-"IFIELD        IGNORE, \"\", \"%s\"            # DMS_LON"
-"IFIELD        IGNORE, \"\", \"%s\"            # UTM"
-"IFIELD        IGNORE, \"\", \"%s\"            # JOG"
-"IFIELD        IGNORE, \"\", \"%s\"            # FC"
-"IFIELD        IGNORE, \"\", \"%s\"            # DSG"
-"IFIELD        IGNORE, \"\", \"%s\"            # PC"
-"IFIELD        IGNORE, \"\", \"%s\"            # CC1"
-"IFIELD        IGNORE, \"\", \"%s\"            # ADM1"
-"IFIELD        IGNORE, \"\", \"%s\"            # ADM2"
-"IFIELD        IGNORE, \"\", \"%s\"            # DIM"
-"IFIELD        IGNORE, \"\", \"%s\"            # CC2"
-"IFIELD        IGNORE, \"\", \"%s\"            # NT"
-"IFIELD        IGNORE, \"\", \"%s\"            # LC"
-"IFIELD        IGNORE, \"\", \"%s\"            # SHORT_FORM"
-"IFIELD        IGNORE, \"\", \"%s\"            # GENERIC"
-"IFIELD        SHORTNAME, \"\", \"%s\"         # SORT_NAME "
-"IFIELD        IGNORE, \"\", \"%s\"            # FULL_NAME (unicoded!)"
-"IFIELD        DESCRIPTION, \"\", \"%s\"               # FULL_NAME_ND"
-"IFIELD        IGNORE, \"\", \"%s\"            # MODIFY_DATE"
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: NIMA/GNIS Geographic Names File\n"
+"# Author: Alex Mottram\n"
+"#   Date: 11/24/2002\n"
+"#\n"
+
+"DESCRIPTION    NIMA/GNIS Geographic Names File\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               TAB\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              TAB\n"
+"PROLOGUE      RC      UFI     UNI     DD_LAT  DD_LONG DMS_LAT DMS_LONG        UTM     JOG     FC      DSG     PC      CC1     ADM1    ADM2    DIM     CC2     NT      LC      SHORT_FORM      GENERIC SORT_NAME       FULL_NAME       FULL_NAME_ND    MODIFY_DATE\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # RC\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # UFI\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # UNI\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%f\"               # DD_LAT\n"
+"IFIELD        LON_DECIMAL, \"\", \"%f\"               # DD_LON\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # DMS_LAT\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # DMS_LON\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # UTM\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # JOG\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # FC\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # DSG\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # PC\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # CC1\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # ADM1\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # ADM2\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # DIM\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # CC2\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # NT\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # LC\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # SHORT_FORM\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # GENERIC\n"
+"IFIELD        SHORTNAME, \"\", \"%s\"         # SORT_NAME \n"
+"IFIELD        IGNORE, \"\", \"%s\"            # FULL_NAME (unicoded!)\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"               # FULL_NAME_ND\n"
+"IFIELD        IGNORE, \"\", \"%s\"            # MODIFY_DATE\n"
 ;
 static char ozi[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Ozi Explorer"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As used in ozi.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMA"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"PROLOGUE      OziExplorer Waypoint File Version 1.1"
-"PROLOGUE      WGS 84"
-"PROLOGUE      Reserved 2"
-"PROLOGUE      Reserved 3"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        INDEX, \"1\", \"%4d\""
-"IFIELD        SHORTNAME, \"\", \"%-14.14s\""
-"IFIELD        LAT_DECIMAL, \"\", \"%11.6f\""
-"IFIELD        LON_DECIMAL, \"\", \"%11.6f\""
-"IFIELD        EXCEL_TIME, \"\", \"%011.5f\""
-"IFIELD        CONSTANT, \"0\", \"%3s\"                # icon "
-"IFIELD        CONSTANT, \"1\", \"%2s\"                # 1 "
-"IFIELD        CONSTANT, \"3\", \"%2s\"                # display format opts "
-"IFIELD        CONSTANT, \"0\", \"%10s\"               # foreground color "
-"IFIELD        CONSTANT, \"65535\", \"%10s\"   # background color "
-"IFIELD        DESCRIPTION, \"\", \"%-40.40s\""
-"IFIELD        CONSTANT, \"0\", \"%2s\"                # pointer direction "
-"IFIELD        CONSTANT, \"0\", \"%2s\"                # garmin display flags "
-"IFIELD        CONSTANT, \"0\", \"%5s\"                # proximity distance "
-"IFIELD        ALT_FEET, \"\", \"%7.0f\""
-"IFIELD        CONSTANT, \"6\", \"%2s\"                # waypt name text size "
-"IFIELD        CONSTANT, \"0\", \"%2s\"                # bold checkbox "
-"IFIELD        CONSTANT, \"17\", \"%2s\"               # symbol size "
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Ozi Explorer\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As used in ozi.c\n"
+"#\n"
+
+"DESCRIPTION           OziExplorer Waypoint\n"
+"EXTENSION             ozi\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMA\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"PROLOGUE      OziExplorer Waypoint File Version 1.1\n"
+"PROLOGUE      WGS 84\n"
+"PROLOGUE      Reserved 2\n"
+"PROLOGUE      Reserved 3\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        INDEX, \"1\", \"%4d\"\n"
+"IFIELD        SHORTNAME, \"\", \"%-14.14s\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%11.6f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%11.6f\"\n"
+"IFIELD        EXCEL_TIME, \"\", \"%011.5f\"\n"
+"IFIELD        CONSTANT, \"0\", \"%3s\"                # icon \n"
+"IFIELD        CONSTANT, \"1\", \"%2s\"                # 1 \n"
+"IFIELD        CONSTANT, \"3\", \"%2s\"                # display format opts \n"
+"IFIELD        CONSTANT, \"0\", \"%10s\"               # foreground color \n"
+"IFIELD        CONSTANT, \"65535\", \"%10s\"   # background color \n"
+"IFIELD        DESCRIPTION, \"\", \"%-40.40s\"\n"
+"IFIELD        CONSTANT, \"0\", \"%2s\"                # pointer direction \n"
+"IFIELD        CONSTANT, \"0\", \"%2s\"                # garmin display flags \n"
+"IFIELD        CONSTANT, \"0\", \"%5s\"                # proximity distance \n"
+"IFIELD        ALT_FEET, \"\", \"%7.0f\"\n"
+"IFIELD        CONSTANT, \"6\", \"%2s\"                # waypt name text size \n"
+"IFIELD        CONSTANT, \"0\", \"%2s\"                # bold checkbox \n"
+"IFIELD        CONSTANT, \"17\", \"%2s\"               # symbol size \n"
 ;
 static char s_and_t[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: MS S&T 2002/2003"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As requested by Noel Shrum on the gpsbabel-code mailing list."
-"# Name,Latitude,Longitude,Name 2,URL,Type"
-"# GCCBF,44.479133,-85.56515,High Rollaway by rjlint,http://www.geocaching.com/seek/cache_details.aspx?ID=3263,Traditional Cache"
-"# GC110D,44.6522,-85.492483,Brown Bridge Pond Peek-a-Boo Cache by Big Bird,http://www.geocaching.com/seek/cache_details.aspx?ID=4365,Traditional Cache"
-"# GC171C,44.70605,-85.62265,The Michigan Frog by RealDcoy & LRB,http://www.geocaching.com/seek/cache_details.aspx?ID=5916,Traditional Cache"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMA"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"PROLOGUE      Name,Latitude,Longitude,Name 2,URL,Type"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"# NOTE: MS S&T ONLY IMPORTS DATA, IT DOESN'T EXPORT THIS ANYWHERE SO WE CAN"
-"#       HAVE OUR WAY WITH THE FORMATTING. "
-"#"
-"IFIELD        SHORTNAME, \"\", \"%s\"         # Name"
-"IFIELD        LAT_DECIMAL, \"\", \"%f\"               # Latitude"
-"IFIELD        LON_DECIMAL, \"\", \"%f\"               # Longitude"
-"IFIELD        DESCRIPTION, \"\", \"%s\"               # Name 2 (Big Description)"
-"IFIELD        URL, \"\", \"%s\"                       # URL"
-"IFIELD        IGNORE, \"\", \"\"                      # Holder for Geocache Type"
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: MS S&T 2002/2003\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As requested by Noel Shrum on the gpsbabel-code mailing list.\n"
+"# Name,Latitude,Longitude,Name 2,URL,Type\n"
+"# GCCBF,44.479133,-85.56515,High Rollaway by rjlint,http://www.geocaching.com/seek/cache_details.aspx?ID=3263,Traditional Cache\n"
+"# GC110D,44.6522,-85.492483,Brown Bridge Pond Peek-a-Boo Cache by Big Bird,http://www.geocaching.com/seek/cache_details.aspx?ID=4365,Traditional Cache\n"
+"# GC171C,44.70605,-85.62265,The Michigan Frog by RealDcoy & LRB,http://www.geocaching.com/seek/cache_details.aspx?ID=5916,Traditional Cache\n"
+"#\n"
+
+"DESCRIPTION           Microsoft Streets and Trips 2002/2003\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMA\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"PROLOGUE      Name,Latitude,Longitude,Name 2,URL,Type\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"# NOTE: MS S&T ONLY IMPORTS DATA, IT DOESN'T EXPORT THIS ANYWHERE SO WE CAN\n"
+"#       HAVE OUR WAY WITH THE FORMATTING. \n"
+"#\n"
+"IFIELD        SHORTNAME, \"\", \"%s\"         # Name\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%f\"               # Latitude\n"
+"IFIELD        LON_DECIMAL, \"\", \"%f\"               # Longitude\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"               # Name 2 (Big Description)\n"
+"IFIELD        URL, \"\", \"%s\"                       # URL\n"
+"IFIELD        IGNORE, \"\", \"\"                      # Holder for Geocache Type\n"
 ;
 static char tiger[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Tiger Data Format"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As defined in tiger.c"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COLON"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COLON"
-
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        LON_DECIMAL, \"\", \"%f\""
-"IFIELD        LAT_DECIMAL, \"\", \"%f\""
-"IFIELD        CONSTANT, \"redpin\", \"%s\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Tiger Data Format\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As defined in tiger.c\n"
+"#\n"
+
+"DESCRIPTION           U.S. Census Bureau Tiger Mapping Service\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COLON\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COLON\n"
+
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        LON_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%f\"\n"
+"IFIELD        CONSTANT, \"redpin\", \"%s\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
 ;
 static char xmap[] = 
-"# gpsbabel XCSV style file"
-"#"
-"# Format: Delorme Xmap Conduit"
-"# Author: Alex Mottram"
-"#   Date: 12/09/2002"
-"#"
-"# "
-"# As defined in csv.c/xmap"
-"#"
-"#"
-"# FILE LAYOUT DEFINITIIONS:"
-"#"
-"FIELD_DELIMITER               COMMASPACE"
-"RECORD_DELIMITER      NEWLINE"
-"BADCHARS              COMMA"
-
-"PROLOGUE      BEGIN SYMBOL"
-"EPILOGUE      END"
-"#"
-"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:"
-"#"
-"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        LON_DECIMAL, \"\", \"%08.5f\""
-"IFIELD        DESCRIPTION, \"\", \"%s\""
+"# gpsbabel XCSV style file\n"
+"#\n"
+"# Format: Delorme Xmap Conduit\n"
+"# Author: Alex Mottram\n"
+"#   Date: 12/09/2002\n"
+"#\n"
+"# \n"
+"# As defined in csv.c/xmap\n"
+"#\n"
+
+"DESCRIPTION           Delorme XMap HH Native .WPT\n"
+"EXTENSION             wpt\n"
+
+"#\n"
+"# FILE LAYOUT DEFINITIIONS:\n"
+"#\n"
+"FIELD_DELIMITER               COMMASPACE\n"
+"RECORD_DELIMITER      NEWLINE\n"
+"BADCHARS              COMMA\n"
+
+"PROLOGUE      BEGIN SYMBOL\n"
+"EPILOGUE      END\n"
+"#\n"
+"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n"
+"#\n"
+"IFIELD        LAT_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        LON_DECIMAL, \"\", \"%08.5f\"\n"
+"IFIELD        DESCRIPTION, \"\", \"%s\"\n"
 ;
 #include "defs.h"
-style_vecs_t style_list[] = {{"xmap", xmap} , {"tiger", tiger} , {"s_and_t", s_and_t} , {"ozi", ozi} , {"nima", nima} , {"mxf", mxf} , {"gpsman", gpsman} , {"gpsdrive", gpsdrive} , {"dna", dna} , {"custom", custom} , {"csv", csv} ,  {0,0}};
+style_vecs_t style_list[] = {{ "xmap", xmap } , { "tiger", tiger } , { "s_and_t", s_and_t } , { "ozi", ozi } , { "nima", nima } , { "mxf", mxf } , { "gpsman", gpsman } , { "gpsdrive", gpsdrive } , { "dna", dna } , { "custom", custom } , { "csv", csv } ,  {0,0}};
index 080d49d1b2ade161352241fe720b1735e3552bc5..db643ca7e419a269e2c9b10eed5e2a2b350326e8 100755 (executable)
@@ -3,9 +3,9 @@ for i in style/*.style
 do
        A=`basename $i | sed "s/.style$//"`
        [ $A = "README" ] && continue
-       ALIST="{\"$A\", $A} , $ALIST"
+       ALIST="{ \"$A\", $A } , $ALIST"
        echo "static char $A[] = "
-       sed 's/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\"/g' $i 
+       sed 's/"/\\"/g;s/\(^.\)/"\1/g;s/\(.$\)/\1\\\n"/g' $i 
        echo ";"
 
 done
diff --git a/gpsbabel/mxf.c b/gpsbabel/mxf.c
deleted file mode 100644 (file)
index 6c4b5dd..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-    Mapsend Exchange Format (.mxf)
-    (Maptech Terrain Navigator, Terrain Professional, Take a Hike)
-    (AKA Yet Another CSV Format) 
-
-    Contributed to gpsbabel by Alex Mottram (geo_alexm at cox-internet.com)
-
-    LAT, LON, "Waypoint Name", "Big Name", "Small Name", COLOR, ICON
-
-    As described in Maptech Terrain Navigator Help File.
-    Tested against Terrain Navigator and ExpertGPS import/export .MXF files.
-
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-#include "csv_util.h"
-
-#define MYNAME "MXF"
-
-static void *mkshort_handle= NULL;
-
-static void
-mxf_set_style()
-{
-    /* set up the csv xcsv_file struct */
-    xcsv_file_init();
-
-    /* this is an internal style, don't mess with it */
-    xcsv_file.is_internal = 1;
-
-    /* how the file gets split up */
-    xcsv_file.field_delimiter = ", ";
-    xcsv_file.record_delimiter = "\n";
-    xcsv_file.badchars = "\",";
-
-    xcsv_ifield_add("LAT_DECIMAL", "", "%08.5f");
-    xcsv_ifield_add("LON_DECIMAL", "", "%08.5f");
-    xcsv_ifield_add("DESCRIPTION", "", "%s");
-    xcsv_ifield_add("SHORTNAME", "", "%s");
-    xcsv_ifield_add("IGNORE", "", "%s");
-    xcsv_ifield_add("CONSTANT", "ff0000", "%s");
-    xcsv_ifield_add("CONSTANT", "47", "%s");
-
-    xcsv_ofield_add("LAT_DECIMAL", "", "%08.5f");
-    xcsv_ofield_add("LON_DECIMAL", "", "%08.5f");
-    xcsv_ofield_add("DESCRIPTION", "", "\"%s\"");
-    xcsv_ofield_add("SHORTNAME", "", "\"%s\"");
-    xcsv_ofield_add("DESCRIPTION", "", "\"%s\"");
-    xcsv_ofield_add("CONSTANT", "ff0000", "%s");
-    xcsv_ofield_add("CONSTANT", "47", "%s");
-
-    /* set up mkshort */
-    if (global_opts.synthesize_shortnames) {
-        setshort_length(mkshort_handle, 32);
-        setshort_whitespace_ok(mkshort_handle, 0);
-        setshort_badchars(mkshort_handle, xcsv_file.badchars);
-    }
-}
-
-static void
-mxf_rd_init(const char *fname, const char *args)
-{
-    mxf_set_style();
-
-    xcsv_file.xcsvfp = fopen(fname, "r");
-    
-    if (xcsv_file.xcsvfp == NULL) {
-        fatal(MYNAME ": Cannot open %s for reading\n", fname );
-    }
-}
-
-static void
-mxf_wr_init(const char *fname, const char *args)
-{
-    mkshort_handle = mkshort_new_handle();
-
-    mxf_set_style();
-
-    xcsv_file.xcsvfp = fopen(fname, "w");
-    
-    if (xcsv_file.xcsvfp == NULL) {
-        fatal(MYNAME ": Cannot open %s for reading\n", fname );
-    }
-}
-
-static void
-mxf_deinit(void)
-{
-    if (xcsv_file.xcsvfp) 
-        fclose(xcsv_file.xcsvfp);
-        
-    xcsv_destroy_style();
-    if ( mkshort_handle)
-           mkshort_del_handle(mkshort_handle);
-    mkshort_handle = NULL;
-}
-
-ff_vecs_t mxf_vecs = {
-    mxf_rd_init,
-    mxf_wr_init,
-    mxf_deinit,
-    mxf_deinit,
-    xcsv_data_read,
-    xcsv_data_write,
-};
diff --git a/gpsbabel/ozi.c b/gpsbabel/ozi.c
deleted file mode 100644 (file)
index 02aa804..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-    OziExplorer Waypoint File Version 1.1 Format (.wpt)
-    Fixed-Length Comma Delimited 
-
-    Contributed to gpsbabel by Alex Mottram (geo_alexm at cox-internet.com)
-
-    As described in Maptech Terrain Navigator Help File.
-    Tested against Terrain Navigator and ExpertGPS import/export .MXF files.
-
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-#include "csv_util.h"
-
-#define MYNAME "OZI"
-
-static void *mkshort_handle = NULL;
-
-
-static void
-ozi_set_style()
-{
-    /* set up the ozi xcsv_file struct */
-    xcsv_file_init();
-
-    /* this is an internal style, don't mess with it */
-    xcsv_file.is_internal = 1;
-
-    /* how the file gets split up */
-    xcsv_file.field_delimiter = ",";
-    xcsv_file.record_delimiter =       "\n";
-    xcsv_file.badchars = ",";
-
-    /* prologue */
-    xcsv_prologue_add("OziExplorer Waypoint File Version 1.1");
-    xcsv_prologue_add("WGS 84");
-    xcsv_prologue_add("Reserved 2");
-    xcsv_prologue_add("Reserved 3");
-
-    /* individual field mappings */
-    xcsv_ifield_add("INDEX", "1", "%4d");
-    xcsv_ifield_add("SHORTNAME", "", "%-14.14s");
-    xcsv_ifield_add("LAT_DECIMAL", "", "%11.6f");
-    xcsv_ifield_add("LON_DECIMAL", "", "%11.6f");
-    xcsv_ifield_add("EXCEL_TIME", "", "%011.5f");
-    xcsv_ifield_add("CONSTANT", "0", "%3s");           /* icon */
-    xcsv_ifield_add("CONSTANT", "1", "%2s");           /* 1 */
-    xcsv_ifield_add("CONSTANT", "3", "%2s");           /* display format opts */
-    xcsv_ifield_add("CONSTANT", "0", "%10s");          /* foreground color */
-    xcsv_ifield_add("CONSTANT", "65535", "%10s");      /* background color */
-    xcsv_ifield_add("DESCRIPTION", "", "%-40.40s");    
-    xcsv_ifield_add("CONSTANT", "0", "%2s");           /* pointer direction */
-    xcsv_ifield_add("CONSTANT", "0", "%2s");           /* garmin display flags */
-    xcsv_ifield_add("CONSTANT", "0", "%5s");           /* proximity distance */
-    xcsv_ifield_add("ALT_FEET", "", "%7.0f");
-    xcsv_ifield_add("CONSTANT", "6", "%2s");           /* waypt name text size */
-    xcsv_ifield_add("CONSTANT", "0", "%2s");           /* bold checkbox */
-    xcsv_ifield_add("CONSTANT", "17", "%2s");          /* symbol size */
-
-    /* outfields are infields */
-    if (xcsv_file.ofield)
-        xfree(xcsv_file.ofield);
-    xcsv_file.ofield = &xcsv_file.ifield;
-    xcsv_file.ofield_ct = xcsv_file.ifield_ct;
-
-    /* set up mkshort */
-    if (global_opts.synthesize_shortnames) {
-        setshort_length(mkshort_handle, 32);
-        setshort_whitespace_ok(mkshort_handle, 0);
-        setshort_badchars(mkshort_handle, xcsv_file.badchars);
-    }
-}
-
-static void
-ozi_rd_init(const char *fname, const char *args)
-{
-    ozi_set_style();
-    
-    xcsv_file.xcsvfp = fopen(fname, "r");
-    
-    if (xcsv_file.xcsvfp == NULL) {
-        fatal(MYNAME ": Cannot open %s for reading\n", fname);
-    }
-}
-
-static void
-ozi_wr_init(const char *fname, const char *args)
-{
-    ozi_set_style();
-
-    mkshort_handle = mkshort_new_handle();
-
-    xcsv_file.xcsvfp = fopen(fname, "w");
-    
-    if (xcsv_file.xcsvfp == NULL) {
-        fatal(MYNAME ": Cannot open %s for reading\n", fname);
-    }
-}
-
-static void
-ozi_deinit(void)
-{
-
-    if (xcsv_file.xcsvfp) 
-        fclose(xcsv_file.xcsvfp);
-        
-    xcsv_destroy_style();
-    if ( mkshort_handle) 
-       mkshort_del_handle(mkshort_handle);
-    mkshort_handle = NULL;    
-}
-
-ff_vecs_t ozi_vecs = {
-    ozi_rd_init,
-    ozi_wr_init,
-    ozi_deinit,
-    ozi_deinit,
-    xcsv_data_read,
-    xcsv_data_write,
-};
index 1d9e77efe231ecec587cc18ef598fc652220acfb..e335102fd44cf9b130f64655ec589fe470833f11 100644 (file)
@@ -40,6 +40,21 @@ Anything after a hash (#) on a line is not parsed.  For example:
 FIELD LAT_DECIMAL, "", "%f"  # ONLY THIS SENTENCE IS A COMMENT.
 
 
+GLOBAL PROPERTIES OF THE FILE:
+--------------------------------
+There are a few available directives to describe traits of the file being
+described and not specific lines appearing the files being described.
+
+ o DESCRIPTION:
+
+   This is the description of the file format being described. This text
+   appears in the help screens and in menus used by the various GUI wrappers.
+
+ o EXTENSION: 
+
+   This directive gives the filename extension generally associated with
+   this file.
+
 DEFINING THE LAYOUT OF THE FILE:
 --------------------------------
 The first few directives define the layout the physical file itself:
index 9236f89830fff59082b00f44d8026051388c9f20..372634acb31545e84d8ae34acf8535463ae46117 100644 (file)
@@ -5,7 +5,8 @@
 #   Date: 12/09/2002
 #
 # 
-# As defined in csv.c
+DESCRIPTION    Comma separated values
+SHORTLEN       8
 #
 #
 # FILE LAYOUT DEFINITIIONS:
index a9fc40b9147da765abe6736b303a614545221343..7a158b60582c674c8e81bdaf3b0c003dbeaf0d4f 100644 (file)
@@ -5,6 +5,9 @@
 #   Date: 11/24/2002
 #
 #
+
+DESCRIPTION            Custom "Everything" Style
+
 # FILE LAYOUT DEFINITIIONS:
 #
 FIELD_DELIMITER                COMMA
index 4b68c1466d2246ad81c6de78a2b61f841d7d1ec2..5cbacbec84e11fd5a4ace70338c6f668b3979ae2 100644 (file)
@@ -8,6 +8,10 @@
 # As defined in dna.c
 #
 #
+
+DESCRIPTION            Navitrak DNA marker format
+EXTENSION              dna
+
 # FILE LAYOUT DEFINITIIONS:
 #
 FIELD_DELIMITER                COMMA
index ced93534876e39ba326a764fe0a936a4bbea5900..aae5de098960d80b6fa7c1d7eabce6bc0032220f 100644 (file)
@@ -6,6 +6,9 @@
 #
 # 
 #
+
+DESCRIPTION            GpsDrive Format
+
 # FILE LAYOUT DEFINITIIONS:
 #
 FIELD_DELIMITER                SPACE
@@ -15,6 +18,10 @@ BADCHARS             ,"
 #
 # INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:
 
-IFIELD ANYNAME, "", "%s"
+IFIELD SHORTNAME, "", "%s"
 IFIELD LAT_DECIMAL, "", "%08.5f"
 IFIELD LON_DECIMAL, "", "%08.5f"
+
+OFIELD ANYNAME, "", "%s"
+OFIELD LAT_DECIMAL, "", "%08.5f"
+OFIELD LON_DECIMAL, "", "%08.5f"
index 711e6b1e02fea5e06169c4f7de81e2b68ad68757..942fcdde94eef3167109e395b7b16dfeecf15eb5 100644 (file)
@@ -8,6 +8,9 @@
 # As defined in gpsman.c
 #
 #
+
+DESCRIPTION            GPSman
+
 # FILE LAYOUT DEFINITIIONS:
 #
 FIELD_DELIMITER                TAB
index 4d00c9a0dd796901b9dcc28feca641ac663d380a..44643f1a2c92999fe584c185e9f432e98ada276f 100644 (file)
@@ -7,6 +7,11 @@
 # 
 # As used in mxf.c
 #
+#
+
+DESCRIPTION            MapTech Exchange Format
+EXTENSION              mxf
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
index 7cc42c254ce927f4ca1cc7a4f7ecdb94d074bcf9..f0562db592e4a108df3de7f8d635a6631be848bc 100644 (file)
@@ -4,6 +4,9 @@
 # Author: Alex Mottram
 #   Date: 11/24/2002
 #
+
+DESCRIPTION     NIMA/GNIS Geographic Names File
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
index dad2123fa916c5d2d63f2b146a1071839b2626b5..9b31b1f119ebb157a4a2c35530decb5a31b91f26 100644 (file)
@@ -7,6 +7,10 @@
 # 
 # As used in ozi.c
 #
+
+DESCRIPTION            OziExplorer Waypoint
+EXTENSION              ozi
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
index 19c5c0a8b1098ad53d3a5309dc2d0e68b8d58fdc..b865a04b7310e57065859cedd88ca3a059c91260 100644 (file)
@@ -11,6 +11,9 @@
 # GC110D,44.6522,-85.492483,Brown Bridge Pond Peek-a-Boo Cache by Big Bird,http://www.geocaching.com/seek/cache_details.aspx?ID=4365,Traditional Cache
 # GC171C,44.70605,-85.62265,The Michigan Frog by RealDcoy & LRB,http://www.geocaching.com/seek/cache_details.aspx?ID=5916,Traditional Cache
 #
+
+DESCRIPTION            Microsoft Streets and Trips 2002/2003
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
index 01170520341e8978586b49d75391cf63b57bd0ab..cf522b6a7cc35a9a854b662c342c3b2da61abcf8 100644 (file)
@@ -7,6 +7,9 @@
 # 
 # As defined in tiger.c
 #
+
+DESCRIPTION            U.S. Census Bureau Tiger Mapping Service
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
index f9453416bd83e26f850222e146123b7b5a23aa55..02bcf0c8b89ab1b8e3084b08b5b863bb014b3608 100644 (file)
@@ -7,6 +7,10 @@
 # 
 # As defined in csv.c/xmap
 #
+
+DESCRIPTION            Delorme XMap HH Native .WPT
+EXTENSION              wpt
+
 #
 # FILE LAYOUT DEFINITIIONS:
 #
diff --git a/gpsbabel/tiger.c b/gpsbabel/tiger.c
deleted file mode 100644 (file)
index ecf9370..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-    Access to  U.S. Census Bureau "tiger" format.
-
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-
-#include "defs.h"
-#include "magellan.h"
-
-static FILE *file_in;
-static FILE *file_out;
-static void *mkshort_handle;
-
-#define MYNAME "GPSUTIL"
-
-static void
-rd_init(const char *fname, const char *args)
-{
-       file_in = fopen(fname, "r");
-       mkshort_handle = mkshort_new_handle();
-
-       if (file_in == NULL) {
-               fatal(MYNAME ": Cannot open %s for reading\n", fname);
-       }
-}
-
-static void
-rd_deinit(void)
-{
-       fclose(file_in);
-       mkshort_del_handle(mkshort_handle);
-}
-
-static void
-wr_init(const char *fname, const char *args)
-{
-       file_out = fopen(fname, "w");
-
-       if (file_out == NULL) {
-               fatal(MYNAME ": Cannot open %s for writing\n", fname);
-       }
-}
-
-static void
-wr_deinit(void)
-{
-       fclose(file_out);
-}
-
-static void
-data_read(void)
-{
-       double lat,lon;
-       char desc[100];
-       char icon[100];
-       char ibuf[1024];
-       waypoint *wpt_tmp;
-
-       while (fgets(ibuf, sizeof(ibuf), file_in)) {
-               if( sscanf(ibuf, "%lf,%lf:%100[^:]:%100[^\n]", 
-                               &lon, &lat, icon, desc)) {
-                       wpt_tmp = xcalloc(sizeof (*wpt_tmp), 1);
-
-                       wpt_tmp->position.longitude.degrees = lon;
-                       wpt_tmp->position.latitude.degrees = lat;
-                       wpt_tmp->description = xstrdup(desc);
-                       wpt_tmp->shortname = mkshort(mkshort_handle, desc);
-
-                       waypt_add(wpt_tmp);
-               }
-       }
-}
-
-static void
-gpsutil_disp(const waypoint *wpt)
-{
-       char *pin;
-       if (wpt->creation_time > time(0) - 3600 * 24 * 14)
-               pin = "greenpin";
-       else
-               pin = "redpin";
-       fprintf(file_out, "%f,%f:%s:%s\n", 
-               wpt->position.longitude.degrees,
-                wpt->position.latitude.degrees,
-                pin,
-                wpt->description);
-}
-
-static void
-data_write(void)
-{
-       fprintf(file_out, "#tms-marker\n");
-       waypt_disp_all(gpsutil_disp);
-}
-
-
-ff_vecs_t tiger_vecs = {
-       rd_init,
-       wr_init,
-       rd_deinit,
-       wr_deinit,
-       data_read,
-       data_write,
-};
index 182692a8b5d9e0c1244651d67755f89d431e2ce0..f53d31cd690761e0408dfa57ed3ef5877eb7966e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <stdio.h>
 #include "defs.h"
+#include "csv_util.h"
 
 typedef struct {
        ff_vecs_t *vec;
@@ -30,46 +31,39 @@ typedef struct {
 } vecs_t;
 
 extern ff_vecs_t geo_vecs;
-extern ff_vecs_t gpsman_vecs;
 extern ff_vecs_t gpx_vecs;
 extern ff_vecs_t mag_vecs;
 extern ff_vecs_t mapsend_vecs;
 extern ff_vecs_t mps_vecs;
 extern ff_vecs_t gpsutil_vecs;
-extern ff_vecs_t tiger_vecs;
 extern ff_vecs_t pcx_vecs;
-extern ff_vecs_t csv_vecs;
 extern ff_vecs_t cetus_vecs;
 extern ff_vecs_t gpspilot_vecs;
 extern ff_vecs_t psp_vecs;
 extern ff_vecs_t garmin_vecs;
-extern ff_vecs_t mxf_vecs;
 extern ff_vecs_t holux_vecs;
-extern ff_vecs_t ozi_vecs;
 extern ff_vecs_t xcsv_vecs;
 extern ff_vecs_t tpg_vecs;
-extern ff_vecs_t dna_vecs;
 extern ff_vecs_t magnav_vec;
-extern ff_vecs_t xmap_vecs;
 extern ff_vecs_t xmapwpt_vecs;
 extern ff_vecs_t tmpro_vecs;
-extern ff_vecs_t gpsdrive_vecs;
 extern ff_vecs_t gcdb_vecs;
 
 static
 vecs_t vec_list[] = {
+       /* XCSV must be the first entry in this table. */
+       {
+               &xcsv_vecs,
+               "xcsv",
+               "? Character Separated Values",
+               NULL
+       },
        {
                &geo_vecs, 
                "geo",
                "Geocaching.com .loc",
                "loc"
        }, 
-       {
-               &gpsman_vecs,
-               "gpsman",
-               "GPSman", 
-               NULL
-       },
        {
                &gpx_vecs,
                "gpx",
@@ -97,7 +91,8 @@ vecs_t vec_list[] = {
        {
                &mps_vecs,
                "mapsource",
-               "Garmin Mapsource"
+               "Garmin Mapsource",
+               NULL
        },
        {
                &gpsutil_vecs,
@@ -105,36 +100,12 @@ vecs_t vec_list[] = {
                "gpsutil", 
                NULL
        },
-       {
-               &tiger_vecs,
-               "tiger",
-               "U.S. Census Bureau Tiger Mapping Service", 
-               NULL
-       },
-       {
-               &csv_vecs,
-               "csv",
-               "Comma separated values", 
-               NULL
-       },
-       {
-               &xmap_vecs,
-               "xmap",
-               "Delorme Topo USA4/XMap Conduit", 
-               NULL
-       },
        {
                &xmapwpt_vecs,
                "xmapwpt",
                "Delorme XMap HH Native .WPT", 
                ".wpt"
        },
-       {
-               &dna_vecs,
-               "dna",
-               "Navitrak DNA marker format",
-               "dna"
-       },
        {
                &psp_vecs,
                "psp",
@@ -165,30 +136,12 @@ vecs_t vec_list[] = {
                "Garmin serial protocol", 
                NULL
        },
-       {
-               &mxf_vecs,
-               "mxf",
-               "MapTech Exchange Format",
-               "mxf"
-       },
        {
                &holux_vecs,
                "holux",
                "Holux (gm-100) .wpo Format",
                "wpo"
        },
-       {
-               &ozi_vecs,
-               "ozi",
-               "OziExplorer Waypoint",
-               "ozi"
-       },
-       {
-               &xcsv_vecs,
-               "xcsv",
-               "? Character Separated Values",
-               NULL
-       },
        {
                &tpg_vecs,
                "tpg",
@@ -201,12 +154,6 @@ vecs_t vec_list[] = {
                "TopoMapPro Places File",
                "tmpro"
        },
-       {
-               &gpsdrive_vecs,
-               "gpsdrive",
-               "GpsDrive Format", 
-               NULL
-       },
        {
                &gcdb_vecs,
                "gcdb",
@@ -226,6 +173,7 @@ ff_vecs_t *
 find_vec(char *const vecname, char **opts)
 {
        vecs_t *vec = vec_list;
+       style_vecs_t *svec = style_list;
        char *v = xstrdup(vecname);
        char *svecname = strtok(v, ",");
 
@@ -255,6 +203,24 @@ find_vec(char *const vecname, char **opts)
                return vec->vec;
                
        }
+
+       /* 
+        * Didn't find it in the table of "real" file types, so plan B
+        * is to search the list of xcsv styles.
+        */
+       while (svec->name) {
+               if (strcmp(svecname, svec->name)) {
+                       svec++;
+                       continue;
+               }
+               xcsv_read_internal_style(svec->style_buf);
+
+               return vec_list[0].vec;
+       }
+       
+       /*
+        * Not found.
+        */
        xfree(v);
        return NULL;
 }
@@ -317,16 +283,27 @@ void
 disp_vecs(void)
 {
        vecs_t *vec;
+       style_vecs_t *svec;
        arglist_t *ap;
 
+#define VEC_FMT "      %-20.20s  %-.50s\n"
+
        for (vec = vec_list; vec->vec; vec++) {
-               printf("        %-20.20s  %-.50s\n",
-                       vec->name, vec->desc);
+               printf(VEC_FMT, vec->name, vec->desc);
                for (ap = vec->vec->args; ap && ap->argstring; ap++) {
                printf("          %-18.18s    %-.50s\n",
                        ap->argstring, ap->helpstring);
                }
        }
+
+       /*
+        * Parse each internal style table in sequence to get the
+        * help strings from it.
+        */
+       for (svec = style_list; svec->name; svec++) {
+               xcsv_read_internal_style(svec->style_buf);
+               printf(VEC_FMT, svec->name, xcsv_file.description);
+       }
 }
 
 /*
@@ -338,9 +315,16 @@ void
 disp_formats(void)
 {
        vecs_t *vec;
+       style_vecs_t *svec;
+
        for (vec = vec_list; vec->vec; vec++) {
                printf("%s\t%s\t%s\n", vec->name, 
                        vec->extension? vec->extension : "", 
                        vec->desc);
        }
+       for (svec = style_list; svec->name; svec++) {
+               xcsv_read_internal_style(svec->style_buf);
+               printf("%s\t%s\t%s\n", svec->name, xcsv_file.extension ? 
+                       xcsv_file.extension : "", xcsv_file.description);
+       }
 }
index f48e75a5866f95f3be08f6e6658b2ee581897565..09d76a6e9b8fb0632e8c8969d12339829eb0e03d 100644 (file)
@@ -188,6 +188,18 @@ xcsv_parse_style_line(const char *sbuff)
                xcsv_file.field_delimiter = sp;
        } else
 
+       if (ISSTOKEN(sbuff, "DESCRIPTION")) {
+               xcsv_file.description = csv_stringtrim(&sbuff[11],"");
+       } else
+
+       if (ISSTOKEN(sbuff, "EXTENSION")) {
+               xcsv_file.extension = csv_stringtrim(&sbuff[10],"");
+       } else
+
+       if (ISSTOKEN(sbuff, "SHORTLEN")) {
+               xcsv_file.shortlen = atoi(&sbuff[9]);
+       } else
+
        if (ISSTOKEN(sbuff, "BADCHARS")) {
            sp = csv_stringtrim(&sbuff[9], "\"");
            cp = get_char_from_constant_table(sp);
@@ -276,6 +288,32 @@ xcsv_parse_style_line(const char *sbuff)
     }
 }
 
+
+/*
+ * A wrapper for xcsv_parse_style_line that reads until it hits
+ * a terminating null.   Makes multiple calls to that function so
+ * that "ignore to end of line" comments work right.
+ */
+static void
+xcsv_parse_style_buff(const char *sbuff)
+{
+       char ibuf[256];
+       char *ibufp;
+       size_t i;
+
+       while (*sbuff) {
+               ibuf[0] = 0;
+               i = 0;
+               for (ibufp = ibuf; *sbuff != '\n' && i++ < sizeof(ibuf); ) {
+                       *ibufp++ = *sbuff++;
+               }
+               while (*sbuff == '\n' || *sbuff == '\r')
+                       sbuff++;
+               *ibufp = 0;
+               xcsv_parse_style_line(ibuf);
+       }
+}
+
 static void
 xcsv_read_style(const char *fname)
 {
@@ -307,6 +345,27 @@ xcsv_read_style(const char *fname)
     fclose(fp);
 }
 
+/*
+ * Passed a pointer to an internal buffer that would be identical
+ * to the series of bytes that would be in a style file, we set up
+ * the xcsv parser and make it ready for general use.
+ */
+void
+xcsv_read_internal_style(const char *style_buf)
+{
+       xcsv_file_init();
+       xcsv_file.is_internal = 1;
+       xcsv_parse_style_buff(style_buf);
+
+       /* if we have no output fields, use input fields as output fields */
+       if (xcsv_file.ofield_ct == 0) {
+               if (xcsv_file.ofield) 
+                       xfree(xcsv_file.ofield);
+               xcsv_file.ofield = &xcsv_file.ifield;
+               xcsv_file.ofield_ct = xcsv_file.ifield_ct;
+       }
+}
+
 static void
 xcsv_rd_init(const char *fname, const char *args)
 {